/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cubelabs.nexus.utils;

import cubelabs.nexus.domain.OrganizationDto;
import cubelabs.nexus.domain.OrganizationRequestDto;
import cubelabs.nexus.entity.Organization;
import cubelabs.nexus.entity.OrganizationRequest;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author chaitanya
 */
public class OrganizationUtil {
 
    public static List<OrganizationDto> getOrganizationDtos(List<Organization> orgList){
        List<OrganizationDto> list = new LinkedList<OrganizationDto>();
        
        for(Organization org:orgList){
            list.add(getOrganizationDto(org));
        }
        return list;
    }

    public static  OrganizationDto getOrganizationDto(Organization org) {
        OrganizationDto organizationDto = new OrganizationDto();
        organizationDto.setId(org.getId());
        organizationDto.setUserId(org.getUser().getId());
        organizationDto.setTitle(org.getTitle());
        organizationDto.setDescription(org.getDescription());
        organizationDto.setLogo(org.getLogopath());
        return  organizationDto;
    }

    public static List<OrganizationRequestDto> getOrganizationRequests(List<OrganizationRequest> list) {
        List<OrganizationRequestDto> orlist = new LinkedList<OrganizationRequestDto>();
        
        for(OrganizationRequest or:list){
            orlist.add(getOrganizationRequestDto(or));
        }
        return orlist;
    }

    private static OrganizationRequestDto getOrganizationRequestDto(OrganizationRequest or) {
        OrganizationRequestDto orDto = new OrganizationRequestDto();
        orDto.setUserId(or.getUser().getId());
        orDto.setOrgId(or.getOrganization().getId());
        orDto.setMessage(or.getMessage());
        return orDto;
    }
}
